I am working on image transition effect while two activities using the new shared elements from lollipop OS. It's working but I get a distorted white blinking on the screen during the transition and I can't find how to implement a solution for this issue.
After doing lots of R&D, i found Same kind of issue here :
To implement a blink effect on the image transition between Android activities, you can use the following code:
Code snippet
public class MainActivity extends AppCompatActivity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
// Get the image from the first activity
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.image);
// Create a Transition object
Transition transition = new Transition();
// Set the transition duration
transition.setDuration(1000);
// Set the transition effect
transition.setInterpolator(new AccelerateDecelerateInterpolator());
// Set the transition image
transition.addTarget(imageView);
// Start the transition
transition.start();
// Start the second activity
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
}
}
This code will first get the image from the first activity. Then, it will create a
Transition object and set its duration and interpolator. Next, it will set the
Transition object's image to the imageView. Finally, it will start the
Transition object and start the second activity.
The Transition object will cause the imageView to blink for 1000 milliseconds before starting the second activity.
To use this code, you need to add the following dependency to your project's
build.gradle file:
This code will add an ImageView widget to the activity_main.xml file. The
ImageView widget will be used to display the image that is being blinked.
Liked By
Write Answer
how to implement blink effect on the image transition between android activites
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy
Join MindStick Community
You have need login or register for voting of answers or question.
Aryan Kumar
02-Jul-2023To implement a blink effect on the image transition between Android activities, you can use the following code:
Code snippet
This code will first get the image from the first activity. Then, it will create a
Transitionobject and set its duration and interpolator. Next, it will set theTransitionobject's image to theimageView. Finally, it will start theTransitionobject and start the second activity.The
Transitionobject will cause theimageViewto blink for 1000 milliseconds before starting the second activity.To use this code, you need to add the following dependency to your project's
build.gradlefile:Code snippet
You also need to add the following code to your project's
activity_main.xmlfile:Code snippet
This code will add an
ImageViewwidget to theactivity_main.xmlfile. TheImageViewwidget will be used to display the image that is being blinked.